export default {
    // mutation 第二个参数对象，没有第三个参数 (state, {num1, num2})
    updateCount(state, num) {
        state.count = num
    },
    getTodos (state, todos) {
        state.todos = todos
    },
    doLogin(state, userInfo) {
        state.user = userInfo
    },
    addTodo (state, todo){
        state.todos.unshift(todo)
    },
    updateTodo(state, {id, todo}){
        state.todos.splice(
            state.todos.findIndex(t => t.id === id),
            1,
            todo
        )
    },
    deleteTodo(state, id){
        state.todos.splice(
            state.todos.findIndex(t => t.id === id),
            1
        )
    },
    deleteAllCompleted(state){
        state.todos = state.todos.filter(t => !t.completed)
    }
}